package com.celer.flex.controller;

import com.celer.flex.entity.User;
import com.celer.flex.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("user")
public class UserController {
    private final UserService userService;

    @GetMapping("/get-by-phone")
    public List<User> getByPhone(@RequestParam("phone") String phone) {
        return userService.getByPhone(phone);
    }

    @PostMapping("/save")
    public User save(@RequestBody User user) {
       return userService.saveUser(user);
    }

    @PostMapping("/del")
    public boolean del(@RequestBody User user){
        return userService.removeById(user);
    }

}
